package priv.lirenhe.javasuper.io.stream2;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class FileReaderWriterStream {
	
	public static void main(String[] args) {
		File sourceFile = new File("F:\\workspace\\java_workspace_01\\huali\\jiwang\\file01");
		File destFile = new File("F:\\workspace\\java_workspace_01\\huali\\jiwang\\file02");
		
		FileReader fReader = null;
		FileWriter fWriter = null;
		try {
			fReader = new FileReader(sourceFile);
			fWriter = new FileWriter(destFile);
			
			int b;
			while((b=fReader.read()) != -1){
				System.out.print((char)b);
				System.out.print(" ");
				fWriter.write(b);
			}
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			if(fWriter != null){
				try {
					fWriter.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if(fReader != null){
				try {
					fReader.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		
	}

}
